package cn.signalpha.modules.system.service.impl;

import cn.signalpha.core.mp.base.BaseServiceImpl;
import cn.signalpha.modules.system.entity.Config;
import cn.signalpha.modules.system.mapper.ConfigMapper;
import cn.signalpha.modules.system.service.IConfigService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import static cn.signalpha.common.cache.CacheNames.CONFIG;

/**
 * 服务实现类
 *
 * @author suguangjun
 */
@Service
public class ConfigServiceImpl extends BaseServiceImpl<ConfigMapper, Config> implements IConfigService {

	@Override
	@Cacheable(cacheNames = CONFIG, key = "#configKey")
	public String getValue(String configKey) {
		Config config = this.getOne(Wrappers.<Config>query().lambda().eq(Config::getConfigKey, configKey));
		return config.getConfigValue();
	}

	@Override
	@CacheEvict(cacheNames = CONFIG, key = "#configKey")
	public void removeCache(String configKey) {
	}

}
